<template>
	<view class="incomeList">
		<view class="header_box flexjus">
			<view class="money_box">
				<view class="top_txt s36 f500 txtali">
					{{listData.incode.today || 0}}
				</view>
				<view class="income_txt s24 family f500 txtali">
					今日收入
				</view>
			</view>
			<view class="money_box">
				<view class="top_txt_c s36 f500 txtali">
					{{listData.incode.money || 0}}
				</view>
				<view class="income_txt s24 family f500 txtali">
					本月收入
				</view>
			</view>
			<view class="money_box">
				<view class="top_txt_c s36 f500 txtali">
					{{listData.incode.year || 0}}
				</view>
				<view class="income_txt s24 family f500 txtali">
					今年收入
				</view>
			</view>
			<view class="money_box">
				<view class="top_txt_c s36 f500 txtali">
					{{listData.incode.total || 0}}万
				</view>
				<view class="income_txt s24 family f500 txtali">
					累计收入
				</view>
			</view>
		</view>
		<view class="picker_dete_box w100">
			<view class="uni-list">
				<view class="uni-list-cell">
					<!-- <view class="uni-list-cell-left s28 family f500">
						2021年01月
					</view> -->
					<view class="uni-list-cell-db">
						<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
							<view class="uni-input">{{date}}</view>
						</picker>
					</view>
				</view>
			</view>
		</view>
		<view class="income_list_box w100">
			<view class="list_box flex" v-for="(item,index) in listData.list" :key="index">
				<view class="left_box_image">
					<image class="w100 h100" src="" mode=""></image>
				</view>
				<view class="right_box_detail">
					<view class="flex">
						<view class="name_txt s30 family f500">
							推荐下单—施华洛总监定推荐下单—施华洛总监定
						</view>
						<view class="money_txt s30 family f500">
							+{{item.money}}
						</view>
					</view>
					<view class="date_txt s24 family f500">
						{{get_date(item.createtime)}}
					</view>
				</view>
			</view>
		</view>
		<view class="bottom_txt s32 familytow fblod txtali">
			暂无明细!
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				date: currentDate,
				listData: {}
			}
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		onLoad() {
			this.getListData()
		},
		methods: {
			getListData() {
				this.$request({
					url: 'user/getIncomeDetail',
					data: {
						date: this.date
					}
				}).then(res => {
					this.listData = res.data.data
				})
			},
			bindDateChange: function(e) {
				this.date = e.detail.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style scoped lang="scss">
	.incomeList {
		overflow: hidden;
		.bottom_txt {
			color: #000;
			margin: 60% auto;
		}
		.income_list_box {
			margin-top: 20upx;
			background-color: #FFFFFF;
			box-sizing: border-box;
			padding: 0 32upx 0 32upx;
			overflow: hidden;

			.list_box {
				height: 140upx;
				margin-top: 32upx;

				.left_box_image {
					width: 80upx;
					height: 80upx;
					border-radius: 50%;
					background-color: #ccc;
				}

				.right_box_detail {
					height: 100%;
					border-bottom: 2upx solid #efefef;
					margin-left: 14upx;

					.name_txt {
						width: 360upx;
						color: #333333;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.money_txt {
						color: #333333;
						margin-left: 150upx;
					}

					.date_txt {
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #666666;
						margin-top: 4upx;
					}
				}
			}
		}

		.picker_dete_box {
			height: 80upx;
			background: #FFFFFF;
			margin-top: 20upx;
			overflow: hidden;

			.uni-list {
				margin-top: 20upx;
				margin-left: 32upx;

				.uni-list-cell-left {
					color: #666666;
				}
			}
		}

		.header_box {
			width: 686upx;
			height: 142upx;
			background: #FFFFFF;
			box-shadow: 0upx 20upx 20upx 2upx rgba(0, 0, 0, 0.06);
			border-radius: 20upx;
			margin: 32upx auto;
			box-sizing: border-box;
			padding: 26upx 56upx 26upx 26upx;

			.money_box {
				width: 126upx;

				.top_txt_c {
					color: #333333;
					font-family: DIN-Medium, DIN;
				}

				.top_txt {
					font-family: DIN-Medium, DIN;
					color: #FF3F4A;
				}

				.income_txt {
					color: #333333;
					margin: 12upx auto;
				}
			}
		}
	}
</style>
<style>
	page {
		background-color: #F4F5F9;
	}
</style>
